import time

from kunlun import lib

# 获取事件日志接口
log = lib.get_event_logger()


# 定义入口函数, 每个文件只有一个入口函数。
def main_sequence():
    log.debug("welcome to main sequence")
    container_name = lib.get_container_name()
    log.debug(container_name)
    lib.set_display1("机型: 1234567890123456")
    lib.set_display2("料号: 1234567890123456")
    lib.set_display3("Slot ID: 1234567890123456")
    uut = lib.se.ref
    uut.open()
    start_time = time.time()
    count = 0
    while time.time() - start_time < 5:
        count += 1
        lib.set_display4(f"测试次数: {count}")
        log.debug(f"第{count}次测试")
        uut.send("python3\r", expect=">>>", timeout=10)
        uut.send("import sys\r", expect=">>>", timeout=10)
        uut.send("sys.platform\r", expect=">>>", timeout=10)
        uut.send("exit()\r", expect=[">", "$"], timeout=10)
    uut.close()
    return
